package com.wedata.wegymer;

import cn.hutool.core.io.file.FileWriter;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class 第N张商卡 {

    public static void main(String[] args) throws IOException {

        FileWriter fileWriter = new FileWriter("C:\\Users\\admin\\Desktop\\mysql.txt");

        FileReader fileReader = new FileReader("src\\main\\java\\com\\wedata\\第N张商卡.txt");
        BufferedReader br = new BufferedReader(fileReader);
        String line = br.readLine();
        String userid = "";
        int cardSeq = 1;
        for(;line!=null;line = br.readLine()){
            String[] ss = line.split("\t");
            if(userid.equals(ss[0])){
                cardSeq++;
            }else{
                cardSeq=1;
            }
            userid = ss[0];
            System.out.println("用户"+ss[0]+"卡"+ss[1]+"是第"+cardSeq+"张商卡");
            fileWriter.append("update trade_membercard set card_seq ="+cardSeq+" where id =" + ss[1]+";");

        }
        br.close();
        fileReader.close();
    }
}
